package edu.fiu.cis.personalize.server.clean;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

import edu.fiu.cis.personalize.server.clean.snowball.SnowballStemmer;
import edu.fiu.cis.personalize.server.clean.snowball.porterStemmer;

public final class Stemmer {
	private Stemmer() {
	}

	private static SnowballStemmer _stemmer = new porterStemmer();

	public static Set<String> stem(String s) {
		Set<String> c = new HashSet<String>();
		s = Cleaner.runCleaners(s);
		s = Normalizer.runNormalizers(s);
		s += " ";
		StringTokenizer st = new StringTokenizer(s, " \t\n\r");
		while (st.hasMoreTokens()) {
			String tok = st.nextToken();
			if (Filter.runFilters(tok)) {
				_stemmer.setCurrent(tok);
				_stemmer.stem();
				c.add(_stemmer.getCurrent());
			}
		}

		return c;
	}

}
